<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<script type="text/javascript">
function moduser(userid)
{
	lf = document.getElementById("listform");
	lf.userid.value = userid;
	lf.action = "preparemod";
	lf.submit();
	return true;
}
function newuser()
{
	lf = document.getElementById("listform");
	lf.action = "preparemod";
	lf.userid.value = "";
	lf.submit();
	return true;
}
function deleteuser(userid)
{	if(confirm('确认要删除吗?')){
		lf = document.getElementById("listform");
		lf.userid.value = userid;
		lf.action = "deleteuser";
		lf.submit();
	}
	return true;
}
function showDefault()
{
	mf = document.getElementById("moduser");
	mf.action = "listuser";
	mf.submit();
	return true;
}
</script>
</head>
<body>
<div>
<table>
<tr>
<td>
用户标识
</td>
<td>
用户名
</td>
<td>
真实姓名
</td>
<td>
状态
</td>
<td>
操作
</td>
</tr>
<form id="listform" method="post">
<input type="hidden" id="userid" name="userid"/>
<s:iterator value="userList" id="user">
<tr>
<td>
<s:property value="#user.userID"/>
</td>
<td>
<s:property value="#user.userName"/>
</td>
<td>
<s:property value="#user.realName"/>
</td>
<td>
<s:property value="#user.status"/>
</td>
<td>
<input type="button" value="修改" onclick="return moduser(<s:property value="#user.userID"/>)"/>
<input type="button" value="删除" onclick="return deleteuser(<s:property value="#user.userID"/>)"/>
</td>
</tr>
</s:iterator>
</form>
</table>
<input type="button" value="新增用户" onclick="return newuser()"/>
</div>
<s:if test="modType == true">
<div>
<s:form action="moduser">
用户名：
<s:if test="null == userid">
<input type="text" maxlength="50" value="<s:property value="user.userName"/>" name="user.userName" />
</s:if>
<s:else>
<input type="hidden" maxlength="50" value="<s:property value="user.userName"/>" name="user.userName" />
<span style="font: bold;"><s:property value="user.userName"/></span>
</s:else><br/>
密码：<input type="password"  name="user.passwd" value="<s:property value="user.passwd"/>" maxlength="16"/><br/>
确认密码：<input type="password" value="<s:property value="user.passwd"/>" name="passwordagain" maxlength="16"/><br/>
email：<input type="text" name="user.email" value="<s:property value="user.email"/>" maxlength="100"/><br/>
昵称：<input type="text" name="user.userNick" value="<s:property value="user.userNick"/>" maxlength="100"/><br/>
真实姓名：<input type="text" name="user.realName" value="<s:property value="user.realName"/>" maxlength="100"/>
<input type="hidden" value="<s:property value="userid"/>" name ="userid"/>
<br/>
<s:if test="null == userid">
<input type="submit" value="新增用户"/>
</s:if>
<s:else>
<input type="submit" value="修改用户"/>
</s:else>
<input type="button" value="取消" onclick="return showDefault()"/>
</s:form>
<s:actionerror/>
</div>
</s:if>
</body>
</html>